/**
 * 
 */
package com.et114.core.common;

import org.apache.commons.configuration.Configuration;
import org.springframework.beans.factory.BeanFactory;


import com.et114.core.utility.ConfigUtil;
import com.et114.core.utility.StrutsMessages;

import org.springframework.util.Assert;
/*
 * @author guanhw
 */
public class AppContext {
	private static BeanFactory springBeans = null;
	private static FrameWorkPropertiesBean  frameWorkPropertiesBean = new FrameWorkPropertiesBean ();
	private static StrutsMessages strutsMessages = new StrutsMessages() ;
	public static String APP_CP ;
	public static String realPath ; 
	public static FrameWorkPropertiesBean getFrameWorkPropertiesBean() {
		return frameWorkPropertiesBean;
	}

	public static void setSpringBeans( BeanFactory springBeans ) {
		AppContext.springBeans = springBeans;
	}
	
	public static StrutsMessages getStrutsMessages() {
		return strutsMessages ;
	}
	
	public static Object getBean( String bn ) {
		Assert.notNull ( springBeans , "没有初始化spring！" ) ;
		return springBeans.getBean( bn  ) ;
	}
	
	
	public static Configuration getConfig()   throws Exception { 
		return new ConfigUtil().getConfiguration() ;
	}

	public static boolean isHasLog( ) {
		return AppContext.getFrameWorkPropertiesBean ( ).getFrameworkLog ( ) .equals ( FrameWorkPropertiesBean.FRAMEWORK_HASLOG )  ;			
	}

	public static void setRealPath ( String realPath ) {
		AppContext.realPath = realPath;
	}
	

}
